﻿



//










//






using System;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using System.Text;
using yb.commerce.Model;
using yb.commerce.BLL;
using Wuqi.Webdiyer;

public partial class back_stage_shopping_method : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            rData_bind();
        }
    }
    private void rData_bind()
    {
        string where="";
        string method = Request.QueryString["method"];

        if (!string.IsNullOrEmpty(method))
            where=" method like '%"+method+"%'";

        string fieldList = "Id,method,remark";
        string orderField = "Id";
        bool orderBy = false;
        DataRecordTable table =new ShoppingMethodBusiness().GetList(fieldList, orderField, orderBy, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, where.ToString());
        rData.DataSource = table.Table;
        rData.DataBind();
        AspNetPager1.RecordCount = table.RecordCount;
        AspNetPager2.RecordCount = table.RecordCount;
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        AspNetPager page = (AspNetPager)sender;
        AspNetPager2.CurrentPageIndex = page.CurrentPageIndex;
        rData_bind();
    }
    protected void AspNetPager2_PageChanged(object sender, EventArgs e)
    {
        AspNetPager page = (AspNetPager)sender;
        AspNetPager1.CurrentPageIndex = page.CurrentPageIndex;
        rData_bind();
    }
    protected void rData_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        string cmd = e.CommandName;
        int id = int.Parse(e.CommandArgument.ToString());
        if (cmd == "update")
        {
            Response.Redirect("shopping_method_detail.aspx?Id=" + id + "&action=update");
        }
        else if (cmd == "delete")
        {
            ShoppingMethodBusiness shoppingMethodBusiness = new ShoppingMethodBusiness();
            shoppingMethodBusiness.Delete(id);
            rData_bind();
        }
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Response.Redirect("shopping_method_detail.aspx");
    }
    protected void btnAllDel_Click(object sender, EventArgs e)
    {
        ShoppingMethodBusiness shoppingMethodBusiness = new ShoppingMethodBusiness();
        CheckBox chkselect = null;
        foreach (RepeaterItem item in rData.Items)
        {
            chkselect = item.FindControl("chkselect") as CheckBox;
            if (chkselect != null && chkselect.Checked)
            {
                int Id = int.Parse(chkselect.ToolTip);
                shoppingMethodBusiness.Delete(Id);
            }
        }
        rData_bind();
    }
}
